# 导入环境
. ~/esp/esp-idf/export.sh

# 创建 build
if [ ! -d "./build/" ];then
    mkdir ./build
else
    rm ./build/* -rf
fi

# 编译
cd ./build
cmake ../src
bear -- make -j10

# 提取 build 中的  compile_commands.json
cp ./compile_commands.json ../

# 提取编译的文件
if [ ! -d "../output/" ];then
    mkdir ../output
else
    rm ../output/* -rf
fi
cp ./foc.bin ../output/
mkdir ../output/bootloader
cp ./bootloader/bootloader.bin ../output/bootloader/
mkdir ../output/partition_table
cp ./partition_table/partition-table.bin ../output/partition_table/
cp ./flash_project_args ../output/
